/*
 * Creative Bulletin Board Generation 3
 * Version 1.0 Beta 1
 +------------------------------------
 * CBB User Interface Javascript
 * Started: August 23, 2009 8:51:20 AM
 +------------------------------------
 */

// DOM Events should be placed in .ready().
$(document).ready(function(){
	//-------------------------------
	// QTip
	// Create the modal backdrop on document load so all modal tooltips can use it
	$('<div id="qtip-blanket">')
		.css({
			position: 'absolute',
			top: $(document).scrollTop(),
			left: 0,
			height: $(document).height(),
			width: '100%',
			opacity: 0.7,
			backgroundColor: 'black',
			zIndex: 5000
		})
		.appendTo($("body")) // Append to the document body
		.hide(); // Hide it initially
	// Then tooltip me
	$('a[href][title]').qtip({
		style: {
			border: {
			   width: 1,
			   radius: 5
			},
			padding: 4, 
			textAlign: 'left',
			tip: true,
			name: 'cream'
		},
	});
});

function niceAlert(data, type){
	if(!type) type = 0;
	box = $(".alert-msg-box");
	if(type == 1){
		box.removeClass("success-msg-box");
		box.addClass("error-msg-box");
	}
	else{
		box.removeClass("error-msg-box");
		if(type == 2) box.addClass("success-msg-box");
		else{
			box.removeClass("success-msg-box");
		}
	}
	box.html(data);
	box.fadeIn(2000, function(){
			box.fadeOut(2000)});
}

//-------------------------------
// Collapse / Expand Tables
function toggle(id){
	$("#table-"+id).slideToggle(350, function(){
		img = document.getElementById("image-"+id);
		if($("#table-"+id).is(":hidden")) {
			img.src = img.src.replace(/up/gi, "down");
		}
		else{
			img.src = img.src.replace(/down/gi, "up");
		}
	});
}

//-------------------------------
// Re-CAPTCHA!
var RecaptchaOptions = {
	theme : 'clean'
};
